<#include "../common/header.htm">
<div class="content-wrapper">
	<section class="content">
			<div class="box">
				<div class="box-header">
					<div class="row RowSearchWork">
						<div class="col-sm-12">
							<div class="form-group">
								<div class="form-inline">
									<div class="form-group ml10">
										<label>操作时间</label>
										<div class="input-group">
											<input type="text" class="form-control pull-right form_datetime" name="beginCreateTimeStr" id="starTime" autocomplete="off" placeholder="请输入发起时间" >
											<div class="input-group-addon">
												<span>至</span>
											</div>
											<input type="text" class="form-control pull-right form_datetime" name="endCreateTimeStr" id="endTime" autocomplete="off" placeholder="请输入结束时间" >
										</div>
									</div>
									<div class="form-group bill-buttonarea" >
										<input type="button" data-event="Show" class="btn btn-primary" value="导入" />
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="table-responsive">
					<table id="table" class="table text-nowrap"></table>
				</div>
			</div>
	</section>
</div>
<script type="text/javascript">

    $(".form_datetime").datepicker({
        format: "yyyy-mm-dd",
        autoclose: true,
        language:'zh-CN',
        pickerPosition:"bottom-left"
    });
    var caseId = parent.caseId;
    $(document).ready(function(){
        query();
        $(window).resize(function(){
            $('#table').datagrid('resize',{
                // height:($(window).height())-150
                height:($(window).height())-($('.stream_search').outerHeight(true))-50,
            });
        });
    });

	function query() {
        $('#table').datagrid({
            url:"${ctx}/report/queryReport",//请求数据url
            pageSize:30,
            pageList:[30,50,100],
            queryParams: {
                caseId:caseId,
            },
            pageNumber:1,//当前页号,
            loadMsg:"正在加载，请稍后",//加载数据时的提示信息
            emptyMsg:"暂无信息",//加载数据为空时的信息
            height: ($(window).height())-($('.stream_search').outerHeight(true))-50,
            rownumbers:true,//序号
            fitColumns: true,//使表格自适应页面宽度
            pagination: true,//是否分页
            singleSelect: true,
            columns: [[
                {
                    field: 'fileName',//域值
                    title: '文件名',//内容
                    visible: true,//false表示不显示
					width:'20%',
                },
                {
                    field: 'createTime',//域值
                    title: '上传时间',//内容
                    width:'20%',
                    visible: true,//false表示不显示
                    formatter: function(value, row, index){
                        if(value){
                            var date = new Date(value);
                            return formatDate(date, 'yyyy-MM-dd hh:mm:ss');
                        }else{
                            return '-';
                        }
                    }
                },
				{
                    field: 'fileSize',//域值
                    title: '文件大小',//内容
                    width:'10%',
                    visible: true,//false表示不显示
                    formatter: function(value, row, index){
                        return getFileSize(value);
					}
                },{
                    field: 'reportType',//域值
                    title: '取证类型',//内容
                    width:'10%',
                    visible: true,//false表示不显示
                    formatter: function(value, row, index){
                        let html = '';
                        switch (value) {
							case 0: html = '美亚电子取证';break;
							case 1: html = '瑞海电子取证';break;
                        }
                        return html;
					}
                },
                {
                    field: 'cccc',//域值
                    title: '操作',//内容
                    align:'center',
                    width:'10%',
                    visible: true,//false表示不显示
                    formatter: function(value, row, index){
                        var html = '';
                        switch (row.reportType) {
                            case 0: html='<a href="${ctx}/file/'+row.fileName+'/'+row.fileName+'.html" target="_blank">查看</a>';break;
                            case 1: html='<a href="${ctx}/file/'+row.fileName+'/'+row.fileName+'.html" target="_blank">查看</a>';break;
                        }
                        return html;
                    }
                }
            ]],
            onHeaderContextMenu: function(e, field){
                e.preventDefault();
                if (!cmenu){
                    createColumnMenu();
                }
                cmenu.menu('show', {
                    left:e.pageX,
                    top:e.pageY
                });
            },
            onLoadSuccess: function(){

            }
        });
    }
    function getFileSize(fileByte) {
        var fileSizeByte = fileByte;
        var fileSizeMsg = "";
        if (fileSizeByte < 1048576) fileSizeMsg = (fileSizeByte / 1024).toFixed(2) + "KB";
        else if (fileSizeByte == 1048576) fileSizeMsg = "1MB";
        else if (fileSizeByte > 1048576 && fileSizeByte < 1073741824) fileSizeMsg = (fileSizeByte / (1024 * 1024)).toFixed(2) + "MB";
        else if (fileSizeByte > 1048576 && fileSizeByte == 1073741824) fileSizeMsg = "1GB";
        else if (fileSizeByte > 1073741824 && fileSizeByte < 1099511627776) fileSizeMsg = (fileSizeByte / (1024 * 1024 * 1024)).toFixed(2) + "GB";
        else fileSizeMsg = "文件超过1TB";
        return fileSizeMsg;
    }

    $('input[data-event=Show]').on('click', function() {
        var d = dialog({
            title: '电子取证信息导入',
            modal:true,
            url: '${ctx}/report/showUpload',
            height:800,
            width:1500,
            onshow: function () {
            },
            onclose: function(event, ui) {
                $('#table').bootstrapTable("refresh");
			}
        });
        d.show();
        return false;
    });

</script>
<style>
	.form-inline {
		margin-bottom: 32px;
	}
	label{
		font-weight: 400;
		font-size: 13px;
		color: #6F7689;
	}
	.form-group {
		margin-left: 10px;
		margin-right: 15px;
	}
	.form-control{
		border-radius:4px;
		font-size: 12px;
	}
	.input-group .input-group-addon {
		border-color: transparent;
	}
	.input-group-addon span {
		font-size: 12px;
		color: #6F7689;
	}
	.form-control:focus {
		border-color:#4595ec;
	}
	.form-control:hover{
		border-color:#4595ec;
	}
	.btn-primary{
		background-color:#4595ec;
		border-color:#4595ec;
		width: 70px;
		height: 32px;
	}
	.btn-primary:hover, .btn-primary:active, .btn-primary.hover{
		background-color:#61a8f5;
		border-color:#61a8f5;
	}
	.btn-primary.focus, .btn-primary:focus{
		background-color:#4595ec;
		border-color:#4595ec;
	}
	._overFlowBeanId{
		word-break:keep-all;
		white-space:nowrap;
		overflow:hidden;
		text-overflow:ellipsis;
	}
</style>